package com.firefly.dao.assembler.cms;

import com.firefly.dao.dao.cms.po.LinkPo;
import com.firefly.dao.dto.cms.LinkDto;
import com.firefly.dao.vo.cms.LinkVo;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * @description: 链接
 * @author: lzg(萤火科技 ： 854378082 @ qq.com)
 * @date: 2022/12/20
 **/
@Component
public class LinkAssembler {
    public List<LinkVo> getListVo(List<LinkPo> list) {
        List<LinkVo> result = new ArrayList<>();
        list.forEach(item -> {
            LinkVo tmp = new LinkVo();
            tmp.setId(item.getId());
            tmp.setLinktypeId(item.getLinktypeId());
            tmp.setTitle(item.getTitle());
            tmp.setThumb(item.getThumb());
            tmp.setUrl(item.getUrl());
            tmp.setSort(item.getSort());
            tmp.setStatus(item.getStatus());
            result.add(tmp);
        });
        return result;
    }

    public LinkPo getPo(LinkDto detail){
        LinkPo entity = new LinkPo();
        entity.setId(detail.getId());
        entity.setLinktypeId(detail.getLinktypeId());
        entity.setTitle(detail.getTitle());
        entity.setThumb(detail.getThumb());
        entity.setUrl(detail.getUrl());
        entity.setSort(detail.getSort());
        entity.setStatus(detail.getStatus());
        return entity;
    }

    public LinkVo getVo(LinkPo entity){
        LinkVo detail = new LinkVo();
        detail.setId(entity.getId());
        detail.setLinktypeId(entity.getLinktypeId());
        detail.setTitle(entity.getTitle());
        detail.setThumb(entity.getThumb());
        detail.setUrl(entity.getUrl());
        detail.setSort(entity.getSort());
        detail.setStatus(entity.getStatus());
        return detail;
    }

}
